home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / sbin / gnome-app-install-helper < prev    next >
Encoding:
Text File  |  2009-03-31  |  1.9 KB  |  58 lines

  1. #!/usr/bin/env python
  2. #  software-properties - graphical abstraction of the sources.list
  3. #  
  4. #  Copyright (c) 2004,2005 Canonical
  5. #                2004,2005 Michiel Sikkes
  6. #  
  7. #  Author: Michiel Sikkes <michiel@eyesopened.nl>
  8. #          Michael Vogt <mvo@debian.org>
  9. #  This program is free software; you can redistribute it and/or 
  10. #  modify it under the terms of the GNU General Public License as 
  11. #  published by the Free Software Foundation; either version 2 of the
  12. #  License, or (at your option) any later version.
  13. #  This program is distributed in the hope that it will be useful,
  14. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. #  GNU General Public License for more details.
  17. #  You should have received a copy of the GNU General Public License
  18. #  along with this program; if not, write to the Free Software
  19. #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  20. #  USA
  21.  
  22. from gettext import gettext as _
  23. import os
  24. import sys
  25. import apt
  26. import apt_pkg
  27.  
  28. from optparse import OptionParser
  29.  
  30. import aptsources
  31. import aptsources.distro
  32. from aptsources.sourceslist import SourcesList
  33.  
  34. if __name__ == "__main__":
  35.   # Begin parsing of options
  36.   parser = OptionParser()
  37.   parser.add_option("-e", "--enable-component", 
  38.                     action="store", type="string", dest="enable_component",
  39.                     help="Enable the specified component of the distro's "\
  40.                     "repositories")
  41.  
  42.   (options, args) = parser.parse_args()
  43.   # Check for root permissions
  44.   if os.geteuid() != 0:
  45.     print _("You need to be root to run this program")
  46.     sys.exit(1)
  47.  
  48.   if options.enable_component:
  49.     sourceslist = SourcesList()
  50.     distro = aptsources.distro.get_distro()
  51.     distro.get_sources(sourceslist)
  52.     distro.enable_component(options.enable_component)
  53.     sourceslist.save()
  54.     print "Enabled the %s component" % options.enable_component
  55.